package com.ihunanren.biz.weixin.domain.school;

import java.util.Date;
import java.util.List;

import com.google.common.collect.Lists;
import com.ihunanren.common.CalendarUtil;
import com.ihunanren.dao.pojo.SchoolCurriculumDefinedDO;
import com.ihunanren.dao.pojo.SchoolCurriculumInfoDO;

/**
 * @author kalman03
 */
public class SchoolCurriculum {

	private final SchoolCurriculumDefinedDO definedDO;
	
	private final List<SchoolCurriculumInfoDO> infoList;

	private final Division division;
	
	public String getLastModified(){
		Date date = definedDO.getGmtModified();
		return CalendarUtil.formatDate(date, "yyyy-MM-dd HH:mm");
	}
	
	public String getSchoolName(){
		return division.getSchoolName();
	}
	
	public String getProvinceName(){
		return division.getProvinceName();
	}
	
	public SchoolCurriculum(SchoolCurriculumDefinedDO definedDO,
			List<SchoolCurriculumInfoDO> infoList) {
		this.definedDO = definedDO;
		this.infoList = infoList;
		this.division = new Division(definedDO.getSchoolId());
	}

	public SchoolCurriculumDefinedDO getDefinedDO() {
		return definedDO;
	}

	public List<SchoolCurriculumInfoDO> getInfoList() {
		return infoList;
	}
	
	public String getLessionDes(int week,int lessionSelect){
		StringBuilder sb = new StringBuilder();
		for(SchoolCurriculumInfoDO infoDO : infoList){
			if(infoDO.getWeek().intValue() == week && infoDO.getLessionSection().intValue() == lessionSelect){
				sb.append(infoDO.getLession()).append("，")
						.append(infoDO.getTeacher()).append("，")
						.append(infoDO.getLocation()).append("，")
						.append(infoDO.getTimeStart()).append("-")
						.append(infoDO.getTimeEnd());
				break;
			}
		}
		return sb.toString();
	}
	/**
	 * 获取最多的课节数
	 * @return
	 */
	private int getMaxLessionSection(){
		int num = 0;
		for(SchoolCurriculumInfoDO infoDO : infoList){
			int num1 = infoDO.getLessionSection().intValue();
			if(num1>num){
				num = num1;
			}
		}
		return num;
	}
	
	public List<Integer> getMaxLessionSectionList(){
		List<Integer> list = Lists.newArrayList();
		for(int i=1;i<=getMaxLessionSection();i++){
			list.add(i);
		}
		return list;
	}
	
	public List<Integer> getMaxWeekList(){
		List<Integer> list = Lists.newArrayList();
		
		int num = 0;
		for(SchoolCurriculumInfoDO infoDO : infoList){
			int num1 = infoDO.getWeek().intValue();
			if(num1>num){
				num = num1;
			}
		}
		for(int i=1;i<=num;i++){
			list.add(i);
		}
		return list;
	}
	public String getChinese(int num){
		String str = "";
		switch (num) {
		case 1:
			str = "一";
			break;
		case 2:
			str = "二";
			break;
		case 3:
			str = "三";
			break;
		case 4:
			str = "四";
			break;
		case 5:
			str = "五";
			break;
		case 6:
			str = "六";
			break;
		case 7:
			str = "七";
			break;
		case 8:
			str = "八";
			break;
		case 9:
			str = "九";
			break;
		default:
			break;
		}
		return str;
	}
	
	public String getWeek(int week){
		String str = "";
		switch (week) {
		case 1:
			str = "一";
			break;
		case 2:
			str = "二";
			break;
		case 3:
			str = "三";
			break;
		case 4:
			str = "四";
			break;
		case 5:
			str = "五";
			break;
		case 6:
			str = "六";
			break;
		case 7:
			str = "天";
			break;

		default:
			break;
		}
		return str;
	}
}
